package com.xgj.controller;

        import org.quartz.Job;
        import org.quartz.JobExecutionContext;
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        import org.springframework.web.client.RestTemplate;
//定时任务
public class MyJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(MyJob.class);

    @Override
    public void execute(JobExecutionContext context) {
        try {
            RestTemplate restTemplate = new RestTemplate();
            String url = "http://localhost:9999/api/random-users/import";
            String response = restTemplate.getForObject(url, String.class);
            logger.info("Job executed successfully. Response: {}", response);
        } catch (Exception e) {
            logger.error("Job execution failed", e);
            throw new RuntimeException(e);  // Quartz会捕获并记录异常
        }
    }
}
